import random
from PIL import Image, ImageDraw, ImageFont

image = Image.new(mode="RGB", size=(200, 40), color=(200, 220, 210))
draw_brush = ImageDraw.Draw(image, mode="RGB")
character_font = ImageFont.truetype('Palatino.ttc', 28)
for i in range(7):
    character = random.choice([chr(random.randint(65, 90)), str(random.randint(0, 9))])
    character_color = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))
    draw_brush.text([i * 30, 0], character, character_color, font=character_font)
with open("test.png", "wb") as f:
    image.save(f, format="png")